import {
  getHeavyLuggagePlaceSelectList
} from '@/pages/mkt/heavyLuggage/service'

export default {
  namespace: 'heavyLuggage',
  state: {
    placeSelectData: [],
  },
  reducers: {
    setPlaceSelectData(state, { payload }) {
      let lastData = payload.map(item => {
        return { label: item, value: item };
      })
      return { ...state, placeSelectData: lastData };
    }
  },
  effects: {
    * getHeavyLuggagePlaceSelectList({ payload, callback, onerror }, { call, put, select }) {
      const response = yield call(getHeavyLuggagePlaceSelectList, payload)
      yield put({
        type: 'setPlaceSelectData',
        payload: response,
      });
    },
  }
};
